﻿

<!--********************* Part1:Jsp Head *********************-->

<%@ page contentType="text/html;charset=UTF-8"%>  
<%@ include file="/framework/head.jsp"%>

<!--********************* Part2:Java Code *********************-->
<%
	CustomerSearchEvent event = (CustomerSearchEvent)context.getSessionValue("CustomerSearchEvent");
	ObjectList list = Customer.fetch().search(con,event);
    System.out.println("begin");
%>

<!--********************* Part3:JavaScript Code ***************-->
<!--start 客户端脚本区域-->
<%@page import="framework.core.ConstDefine"%>
<script language=javascript>

var headid = "<%=ConstDefine.CUSTOMER_HEAD_ID%>";
var list_code = "listCustomer";
//修改 
function chk1(){
    var obj = getCheckBoxValues("ids");
    for(var i = 0; i < obj.length;i++){
        if(obj[i] == headid){
            alert("顶级用户不允许进行修改");
            return false;
        }
    }
    return true;
}

//删除
function chk2(){
    var obj = getCheckBoxValues("ids");
    for(var i = 0; i < obj.length;i++){
        if(obj[i] == headid){
            alert("删除选择了顶级用户,顶级用户不允许删除");
            return false;
        }
    }
    return true;
}

function doSearch()
{
	SetValue("s_Code",GetValue("i_Code")); //编码

	SetValue("s_Name",GetValue("i_Name")); //名称
    
	SetValue("s_IsBalance",GetValue("i_IsBalance")); //是否结算单位

	SetValue("s_IsDraw",GetValue("i_IsDraw")); //是否领料单位
    
    SetValue("s_Status",GetValue("i_Status")); //是否有效

	SetValue("s_WarehouseCode",GetValue("i_WarehouseCode")); //仓库编码

	SetValue("s_OrderField",GetValue("i_OrderField")); //排序
	SetValue("s_OrderDesc",getCheckBoxValues("i_OrderDesc")); //升降序
	doCommonSearch();
}

function bizViewCustomer(id)
{
	viewWin("<%=Config.getSrv()%>?action_code=viewCustomer&Id="+id);
}

function doDelete()
{
    if(!chk2()) return false; 
    
	if(!hasChooseRadio("ids"))
	{
		bizMessage("删除","客户");
		return false;
	}
	if(!bizConfirm("删除","客户")) return false;
	SetAction("deleteCustomer");
	frm.submit();
}

function doToAdd()
{
    if(!checkOne("ids")) 
    {
        bizMessage("添加下级","上级客户");
        return false;
    }
    SetValue("Id",getCheckBoxValue("ids"));
	SetAction("toAddCustomer");
	frm.submit();
}

function doToUpdate()
{
	if(!checkOne("ids")) 
	{
		bizMessage("修改","客户");
		return false;
	}
    
    if(!chk1()) return false; 
    
	SetValue("Id",getCheckBoxValue("ids"));
	SetAction("toUpdateCustomer");
	frm.submit();
}

function doToCopy()
{
	if(!checkOne("ids")) 
	{
		bizMessage("复制","客户");
		return false;
	}
	SetValue("Id",getCheckBoxValue("ids"));
	SetAction("toCopyCustomer");
	frm.submit();
}

function doStaffManage()
{
    if(!checkOne("ids"))
    {
        bizMessage("员工信息管理","客户");
        return false;
    }
    SetValue("CustomerID",getCheckBoxValue("ids"));
    SetAction("listCustomerStaff");
    frm.submit();
}

key_InitDefault();
key_RegSubmitHandler(doSearch);
</script>


<%=uiBody%>>

<%@ include file="/framework/menu.jsp"%>

<!--********************* Part4:Form  ***************-->
<form id=frm action="<%=Config.getSrv()%>" method="post">
<input type=hidden name="action_code" value="">
<input type=hidden name="Id" value="">
<input type=hidden name=sortOrder value="1">
<input type=hidden name=CustomerID value="1">

<!--查询条件保留区域-->

<input type=hidden name="s_WarehouseCode" value="<%=event.getWarehouseCode()%>"> <!--仓库编码-->

<input type=hidden name="s_Code" value="<%=event.getCode()%>"> <!--编码-->

<input type=hidden name="s_Name" value="<%=event.getName()%>"> <!--名称-->

<input type=hidden name="s_IsDraw" value="<%=event.getIsDraw()%>"> <!--是否领料单位-->

<input type=hidden name="s_IsBalance" value="<%=event.getIsBalance()%>"> <!--是否结算单位-->

<input type=hidden name="s_Status" value="<%=event.getStatus()%>"> <!--是否有效-->

<%@ include file="/framework/list_head.jsp"%>

<br>
<!--********************* Part5:Search Area ***************-->
<%=uiSearchStart%>>
<%
	int key_tab = 1 ;
%>

	<%=uiSearchInputTR%>>
        <%=uiSearchInputTDHead%>>
            默认配送仓库：
           <%=SelectManager.viewWarehouseSelect(con,loginInfo.getLoginWarehouseCode(),"i_WarehouseCode",event.viewWarehouseCode(),true,"",SelectManager.SELECT_ALL,"","key_tab="+(key_tab++))%>
            编&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码：
           <input type="text" class="texts" name="i_Code" size="20" value="<%=event.viewCode()%>" key_tab="<%=key_tab++%>">
            名&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;称：
           <input type="text" class="texts" name="i_Name" size="20" value="<%=event.viewName()%>" key_tab="<%=key_tab++%>">
		</td>		
	</tr>

	<%=uiSearchInputTR%>>
		<%=uiSearchInputTDHead%>>
            是否领料单位：
           <%=SelectManager.viewYesOrNoSelect("i_IsDraw",event.viewStatus(),true,"",SelectManager.SELECT_ALL,"","key_tab="+(key_tab++))%>
            是否结算单位：
           <%=SelectManager.viewYesOrNoSelect("i_IsBalance",event.viewStatus(),true,"",SelectManager.SELECT_ALL,"","key_tab="+(key_tab++))%>
            有&nbsp;&nbsp;&nbsp;效&nbsp;&nbsp;&nbsp;性：
           <%=SelectManager.viewValidOrNoSelect("i_Status",event.viewStatus(),true,"",SelectManager.SELECT_ALL,"","key_tab="+(key_tab++))%>
		</td>		
	</tr>

	<%=uiSearchInputTR%>>
		<%=uiSearchInputTDHead%>>
			按&nbsp;&nbsp;&nbsp;排&nbsp;&nbsp;&nbsp;序：
			
			<select name="i_OrderField">
                <option value="" <%=(event.getOrderField().equals("1"))?"selected":""%>>设置排序字段</option>
                
				<option value="CODE" <%=(event.getOrderField().equals("CODE"))?"selected":""%>>编码</option>
				
				<option value="NAME" <%=(event.getOrderField().equals("NAME"))?"selected":""%>>名称</option>
				
				<option value="IS_BALANCE" <%=(event.getOrderField().equals("IS_BALANCE"))?"selected":""%>>是否结算单位</option>
				
				<option value="IS_DRAW" <%=(event.getOrderField().equals("IS_DRAW"))?"selected":""%>>是否领料单位</option>
                
                <option value="STATUS" <%=(event.getOrderField().equals("STATUS"))?"selected":""%>>有效性</option>
				
				<option value="WAREHOUSE_CODE" <%=(event.getOrderField().equals("WAREHOUSE_CODE"))?"selected":""%>>默认配送仓库</option>
				
			</select>
			&nbsp;&nbsp;
			<input type="radio" name="i_OrderDesc" value="false" <%=(event.isOrderDesc()==false)?"checked":""%> >升序
			<input type="radio" name="i_OrderDesc" value="true"  <%=(event.isOrderDesc()==true)?"checked":""%>  >降序
			<input type="button" value="查询" class="buttons" onclick="doSearch();return false;">&nbsp;<input type="button" value="清空" class="buttons" onclick="doClearEvent();return false;">
		</td>
	</tr>

<%=uiSearchEnd%>

<!--列表标题-->
<%=UIManager.addListHeadTitle("客户列表")%>

<!--********************* Part6:List Area ***************-->

<%=uiListStart%>>

<%@ include file="/framework/list_foot.jsp"%>

<%
	int index = 1 ;
%>	
	<%=uiListHeadTR%>>
		<%=UIManager.addListHeadCheckBox() %>

		<%=UIManager.addListHead("编码",index++)%>

		<%=UIManager.addListHead("名称",index++)%>

		<%=UIManager.addListHead("是否结算单位",index++)%>

		<%=UIManager.addListHead("是否领料单位",index++)%>
        
        <%=UIManager.addListHead("有效性",index++)%>

		<%=UIManager.addListHead("默认配送仓库",index++)%>

		<%=UIManager.addListHead("操作",-1)%>  
	<%=uiListHeadTREnd%>>
	
	<!--data-->
<%
	for(int i=0;i<list.size();i++)
	{
		Customer obj = (Customer)list.get(i);
%>
	<%=uiListDataTR[i%2]%> align=center>
    	<%=uiListDataTD%>>
        <%
        String str = obj.viewCode(con);
        if(str.equals("00")){ %>
            <input type="checkbox" id="objid" name="ids"  value="<%=obj.getId()%>">
         <%}else{ %>
            <input type="checkbox" id="objid" name="ids"  value="<%=obj.getId()%>">
         <%} %>
    	</td>
    
    	<%=uiListDataTD%>><%=obj.viewCode(con)%></td>
    
    	<%=uiListDataTD%>><%=obj.viewName(con)%></td>
    
    	<%=uiListDataTD%>><%=obj.viewIsBalance(con)%></td>
    
    	<%=uiListDataTD%>><%=obj.viewIsDraw(con)%></td>
        
        <%=uiListDataTD%>><%=obj.viewStatus(con)%></td>
    
    	<%=uiListDataTD%>><%=obj.viewWarehouseName(con)%></td>

    	<%=uiListDataTD%>>
    		<a href="" onclick="bizViewCustomer('<%=obj.getId()%>');return false;">浏览</a>
    	</td>
  	</tr>
<%	
	}
%>  

<%@ include file="/framework/list_foot2.jsp"%>

<%=uiListEnd%>


<!--********************* Part7:Action Area ***************-->
<%=uiCommandStart%>>
	<%=uiCommandTR%>>
		<%=uiCommandTD%>>
		<input type=button value=" 添加下级 " class="buttons" onclick="doToAdd();return false;">
		<!--
		<input type=button value="   复制   " class="buttons" onclick="doToCopy();return false;">
		-->
		<input type=button value="   修改   " class="buttons" onclick="doToUpdate();return false;">
		<!--  <input type=button value="   删除   " class="buttons" onclick="doDelete();return false;">-->
        <input type=button value="员工信息管理" class="buttons" onclick="doStaffManage();return false;">
		</td>
	</tr>	
<%=uiCommandEnd%>
</form>


<%@ include file="/framework/foot.jsp"%>

<!--
	Author    :Wing
	FileName  :/system/base/CustomerList.jsp
-->
